In this script, there is conducted the estimation for the measure_marginal approach for a single given env. The programs is the set of bytecode programs with varying number of opcodes. The measurements are time measurements of program runs or benchmarks. The estimation of each opcode is calculated as the regression against the number of a given opcode in the executed programs.

Parametrization. The evm client name env=besu, the file with programs programs=pg_marginal_full_step5_v2.csv, the file with measurements results=results_marginal_full_besu.csv,
the output csv file with estimated cost output_estimated_cost=reports-08.11.2024/estimated_cost_besu_full.csv, should the details be included in the report details=FALSE.

The comparision of result. Before and after removing outlying measurement. Switch removed_outliers to FALSE to see the comparison.

if (removed_outliers) {
  measurements = remove_compare_outliers(measurements, 'measure_total_time_ns', c(env))
}

Now we can investigate the linear regressions.

for (opcode in all_opcodes) {
  estimate = compute_all(opcode=opcode, env=env, use_median=TRUE, plots=ifelse(details,'all','scatter'))
  estimates[nrow(estimates) + 1, ] = c(opcode, estimate, env)
}

The resulting estimates based on the regressions above.

estimates
##                 op estimate_marginal_ns estimate_marginal_ns_stderr  env
## 1              ADD            37.275455                   1.7119413 besu
## 2              MUL            42.329091                   1.4265692 besu
## 3              SUB            35.378182                   1.5496095 besu
## 4              DIV            30.285455                   1.5663110 besu
## 5             SDIV            34.705455                   2.1918198 besu
## 6              MOD            84.959091                   3.6092677 besu
## 7             SMOD            84.746364                   3.4349348 besu
## 8           ADDMOD           102.930000                   3.2548627 besu
## 9           MULMOD           105.895455                   3.7000223 besu
## 10             EXP           158.535455                   4.3453711 besu
## 11      SIGNEXTEND            61.428182                   1.6852234 besu
## 12              LT            11.708182                   2.7123274 besu
## 13              GT            13.567273                   2.5901605 besu
## 14             SLT            25.192727                   1.8211818 besu
## 15             SGT            25.200909                   1.0032014 besu
## 16              EQ            13.644545                   1.0752862 besu
## 17          ISZERO             7.222727                   2.3804082 besu
## 18             AND            20.050000                   1.6284572 besu
## 19              OR            21.189091                   1.7041799 besu
## 20             XOR            20.550000                   2.0424659 besu
## 21             NOT            39.414545                   2.0342667 besu
## 22            BYTE             9.175455                   1.8235263 besu
## 23             SHL            51.022727                   1.8767016 besu
## 24             SHR            51.784545                   1.6066274 besu
## 25             SAR            52.656364                   0.9264938 besu
## 26       KECCAK256           353.981818                   2.5777272 besu
## 27         ADDRESS             4.305455                   1.0167398 besu
## 28          ORIGIN             4.056364                   0.9754242 besu
## 29          CALLER             4.326364                   0.9520660 besu
## 30       CALLVALUE             4.730000                   1.0492181 besu
## 31    CALLDATALOAD             6.928182                   1.6885870 besu
## 32    CALLDATASIZE             9.358182                   0.3989315 besu
## 33    CALLDATACOPY            37.097273                   2.9788913 besu
## 34        CODESIZE             9.510909                   0.3364150 besu
## 35        CODECOPY            52.225455                   2.6528765 besu
## 36        GASPRICE             3.752727                   0.9037914 besu
## 37     EXTCODESIZE            72.011818                   2.7606069 besu
## 38     EXTCODECOPY            87.063636                   2.9042498 besu
## 39  RETURNDATASIZE            10.455455                   0.3240071 besu
## 40  RETURNDATACOPY            46.326364                   5.0233528 besu
## 41     EXTCODEHASH            65.587273                   4.3460126 besu
## 42        COINBASE             3.970909                   0.8700884 besu
## 43       TIMESTAMP            10.488182                   0.7548856 besu
## 44          NUMBER            10.132727                   0.4693962 besu
## 45      DIFFICULTY             7.487273                   0.8341596 besu
## 46        GASLIMIT             9.500909                   0.4951944 besu
## 47         CHAINID             7.516364                   0.6961363 besu
## 48     SELFBALANCE             8.098182                   0.2804522 besu
## 49             POP             8.750909                   1.1608792 besu
## 50           MLOAD            29.016364                   1.8184398 besu
## 51          MSTORE            36.842727                   1.1257839 besu
## 52     MSTORE_COLD            51.040909                   1.3866448 besu
## 53         MSTORE8            25.320000                   2.6436433 besu
## 54            JUMP             6.290909                   0.6297798 besu
## 55           JUMPI            14.412727                   2.3872820 besu
## 56              PC             9.595455                   0.2829588 besu
## 57           MSIZE            10.794545                   0.3014876 besu
## 58             GAS            10.399091                   0.5507770 besu
## 59        JUMPDEST             2.873636                   0.3240100 besu
## 60           MCOPY            32.630909                   2.9813024 besu
## 61      MCOPY_COLD            30.930000                   6.0402219 besu
## 62           PUSH0             4.550000                   0.3739515 besu
## 63            LOG0            32.144545                   1.6354745 besu
## 64            LOG1            68.913636                   0.9565978 besu
## 65            LOG2           101.688182                   1.0052548 besu
## 66            LOG3           139.057273                   2.3019860 besu
## 67            LOG4           168.317273                   1.4598728 besu
## 68          CREATE          4208.726364                  79.6801269 besu
## 69            CALL          1092.954545                   8.1710539 besu
## 70          RETURN            18.745455                  11.1131578 besu
## 71    DELEGATECALL           695.457273                  11.5498998 besu
## 72      STATICCALL           792.821818                  14.0466457 besu
## 73          REVERT           187.003636                   9.6114624 besu
## 74           PUSH1            10.900000                   1.4473966 besu
## 75           PUSH2            14.620000                   1.3854085 besu
## 76           PUSH3            14.937273                   1.2045178 besu
## 77           PUSH4            17.131818                   1.5616394 besu
## 78           PUSH5            20.080000                   1.1482080 besu
## 79           PUSH6            20.406364                   1.3825872 besu
## 80           PUSH7            23.159091                   1.7249851 besu
## 81           PUSH8            24.931818                   1.3432303 besu
## 82           PUSH9            27.794545                   1.4726813 besu
## 83          PUSH10            28.782727                   1.5337261 besu
## 84          PUSH11            29.966364                   1.2129524 besu
## 85          PUSH12            33.530000                   1.2750985 besu
## 86          PUSH13            34.300000                   1.2286733 besu
## 87          PUSH14            37.239091                   1.4465148 besu
## 88          PUSH15            39.744545                   1.2834784 besu
## 89          PUSH16            41.486364                   1.9810622 besu
## 90          PUSH17            41.951818                   1.3896624 besu
## 91          PUSH18            43.277273                   1.3720754 besu
## 92          PUSH19            44.682727                   1.3941785 besu
## 93          PUSH20            48.455455                   1.6071397 besu
## 94          PUSH21            49.511818                   1.3984450 besu
## 95          PUSH22            50.848182                   1.5142922 besu
## 96          PUSH23            54.165455                   1.2191062 besu
## 97          PUSH24            53.332727                   1.5108595 besu
## 98          PUSH25            54.749091                   1.2966993 besu
## 99          PUSH26            59.864545                   0.6105048 besu
## 100         PUSH27            60.800909                   0.4591163 besu
## 101         PUSH28            60.707273                   0.4222547 besu
## 102         PUSH29            66.411818                   1.1196546 besu
## 103         PUSH30            67.015455                   1.2016323 besu
## 104         PUSH31            68.061818                   1.2215744 besu
## 105         PUSH32            71.510000                   1.4510102 besu
## 106           DUP1             7.883636                   2.5414127 besu
## 107           DUP2             6.150909                   1.8008085 besu
## 108           DUP3             8.045455                   1.8330969 besu
## 109           DUP4             6.315455                   1.8282075 besu
## 110           DUP5             7.148182                   1.9485384 besu
## 111           DUP6             6.903636                   1.9498031 besu
## 112           DUP7             4.998182                   1.0523085 besu
## 113           DUP8             4.667273                   0.8492683 besu
## 114           DUP9             6.100909                   1.9576119 besu
## 115          DUP10             6.829091                   1.8344609 besu
## 116          DUP11             4.396364                   0.9786614 besu
## 117          DUP12             7.978182                   2.0810828 besu
## 118          DUP13             5.160000                   0.5749487 besu
## 119          DUP14             4.291818                   1.0724456 besu
## 120          DUP15             6.827273                   1.6044383 besu
## 121          DUP16             4.518182                   1.1462471 besu
## 122          SWAP1             9.444545                   1.3584419 besu
## 123          SWAP2             9.884545                   1.1463821 besu
## 124          SWAP3            10.165455                   1.2399856 besu
## 125          SWAP4             9.960909                   1.2322604 besu
## 126          SWAP5            10.065455                   1.1773348 besu
## 127          SWAP6            11.906364                   1.3438979 besu
## 128          SWAP7            14.201818                   1.3570026 besu
## 129          SWAP8            10.434545                   1.2870078 besu
## 130          SWAP9            10.223636                   1.2620593 besu
## 131         SWAP10            14.854545                   1.5018874 besu
## 132         SWAP11            10.308182                   1.2545432 besu
## 133         SWAP12            11.870909                   1.4471090 besu
## 134         SWAP13            11.918182                   1.3390353 besu
## 135         SWAP14            10.790909                   1.3406980 besu
## 136         SWAP15            14.122727                   1.7237565 besu
## 137         SWAP16            13.927273                   1.5293618 besu

The results are exported to reports-08.11.2024/estimated_cost_besu_full.csv.